<?php 

class CategoryController extends AuthController{
	private $db;
	public function __init()
	{
		$this->db=K('Category');
		
	}
	//显示问题栏目
	public function index()
	{	
		$data=$this->db->getList();
		$this->assign('data',$data);
		$this->display();
	}
	//添加问题栏目
	public function add()
	{
		if (IS_POST) {
			if($this->db->addCategory()){
				$this->success('添加成功','index');
			}else{
				$this->error($this->db->error);
			}
		}else{
			$this->display();
		}
	}
	//编辑问题栏目
	public function edit()
	{
		if (IS_POST) {
			if ($this->db->editCategory()) {
				$this->success('编辑成功','index');
			}else{
				$this->error($this->db->error);
			}
		}else{
			$cat=$this->db->find(Q('cid'));
			$this->assign('cat',$cat);
			$this->display();
		}
	}
	public function del()
	{
		if ($this->db->delCategory()) {
			$this->success('删除成功','index');
		}else{
			$this->error($this->db->error);
		}
	}

}

 ?>